

import { ItemModel } from "core/model/itemModel"
import fighterHandle from "./fighterHandle"
import partnerHandle from "./partnerHandle"
import { PlayerModel } from "core/model/playerModel"
import { FighterModel } from "core/model/fighterModel"
import { gameConfigHandle } from "core/config/gameConfig"

class FighterPetHandle {
    createPetFighter(pet: ItemModel) {
        let fighter = new FighterModel()
        fighter.tid = pet.tid
        let petItemConfig = gameConfigHandle.configByID[pet.tid]
        this.getAttris(pet, fighter)
        fighterHandle.calcBattleFighterAttri(fighter)
        fighter.battleAttris.hp = fighter.battleAttris.maxHp

        return fighter
    }

    createPetFighter2(player: PlayerModel, pet: ItemModel) {
        let fighter = new FighterModel()
        fighter.tid = pet.tid
        let petItemConfig = gameConfigHandle.configByID[pet.tid]
        this.getAttris(pet, fighter)
        this.getSkills(pet, fighter)
        fighterHandle.calcBattleFighterAttri(fighter)
        fighter.battleAttris.hp = fighter.battleAttris.maxHp
        return fighter
    }

    getAttris(pet: ItemModel, fighter: FighterModel) {
        let petConfig = gameConfigHandle.gameConfig.pet
        let attriLvlupConfig = gameConfigHandle.gameConfig.attriLvlup
        // petConfig.petQualityAttriList.forEach((attriName, i) => {
        //     let value = partnerHandle.getAttriValues(attriName, pet.pet.lvl, attriLvlupConfig.petQualityAttriValues)
        //     let elementAttriAdd = 1
        //     if (pet.pet.elements.indexOf(i) !== -1) {
        //         elementAttriAdd = 1 + petConfig.elementAttriAdd * (pet.pet.quality + 1) / 100
        //     }
        //     fighter.attris[attriName] += value * elementAttriAdd * (1 + petConfig.attriCoeAdd * ((pet.pet.attriQualitys1[i] || 0) + (pet.pet.attriQualitys2[i] || 0)) / 100)
        // })
    }

    getSkills(pet: ItemModel, fighter: FighterModel, partnerPet?: FighterModel) {
        // let petConfig = gameConfigHandle.gameConfig.petAttri
        // let petItemConfig = gameConfigHandle.configByIDCopy[pet.tid]
        // if (petItemConfig.Skills) {
        //     petItemConfig.Skills.forEach(skillID => {
        //         fighter.Skills.push([skillID, 1])
        //     })
        // }
        // pet.pet.Skills.forEach(skillItem => {
        //     fighter.Skills.push([skillItem[0], skillItem[1]])
        // })
    }

}


let fighterPetHandle = new FighterPetHandle()

export default fighterPetHandle
